public class Gloves {
    public int findMinimum(int n, int[] left, int[] right) {
        //****Sum用于记录某一只手套所有颜色数量之和
        int leftSum = 0;
        int rightSum = 0;
        int leftMin = Integer.MAX_VALUE;
        int rightMin = Integer.MAX_VALUE;
        int sum = 0;
        for (int i = 0; i < n; i++) {
            //判断：其中一只手的手套的颜色为0的情况
            if(left[i] * right[i] == 0){
                sum += left[i] + right[i];
            }else {
                leftSum += left[i];
                rightSum += right[i];
                //分别寻找左/右手手套中数量最少的颜色的数量
                if (leftMin > left[i]){
                    leftMin = left[i];
                }
                if (rightMin > right[i]){
                    rightMin = right[i];
                }
            }
        }
        return Math.min(leftSum-leftMin+1,rightSum-rightMin+1)+1+sum;
    }
}
